package main

import (
	"flag"
	"fmt"
	"log"
	"net"
	"youku/youku-srv/basic/config"
	"youku/youku-srv/basic/inits"
	__ "youku/youku-srv/basic/proto"
	"youku/youku-srv/services"

	"google.golang.org/grpc"
)

func main() {
	flag.Parse()
	lis, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:50051"))
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	config.InitConfig()
	inits.InitMysql()
	inits.InitRedis()
	__.RegisterYouKuServer(s, &services.Server{})
	log.Printf("server listening at %v", lis.Addr())
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}
